package bll

import (
	"lutai/src/schema"
	"lutai/src/util"
	"time"
)

// Test 业务处理
type Test struct {
	*Bll
}

// Create 创建
func (a *Test) Create(t *schema.Test) error {
	t.RecordID = util.UUID()
	t.Created = time.Now().Unix()
	return a.Models.Test.Create(t)
}

// Update 更新
func (a *Test) Update(t *schema.Test) error {
	info := util.StructToMap(t)
	delete(info, "ID")
	delete(info, "RecordID")
	delete(info, "Created")
	return a.Models.Test.Update(t.RecordID, info)
}

// Delete 删除
func (a *Test) Delete(id string) error {
	return a.Models.Test.Delete(id)
}

// Get 获取单条数据
func (a *Test) Get(id string) (*schema.Test, error) {
	return a.Models.Test.Get(id)
}

// Query 查询
func (a *Test) Query() ([]*schema.Test, error) {
	return a.Models.Test.Query()
}
